package com.mstore.service;

import java.util.ArrayList;
import java.util.List;

import com.mstore.dao.GoodsDao;
import com.mstore.pojo.Goods;

public class GoodsService {
	private GoodsDao goodDao;

	public boolean Delete(Goods good){
		return goodDao.Delete(good);
	}
	
	public boolean save(Goods good){
		return goodDao.save(good);
	}
	
	public List<Goods>getList(Goods good,int index){
		List<Goods>goodList=new ArrayList<Goods>();
		List<Object>objects=goodDao.getList(good, index);
		
		for (Object object : objects) {
			Goods g=(Goods) object;
			goodList.add(g);
		}
		return goodList;
	}
	
	public Goods FindById(long id){
		return goodDao.FindById(id);
	}
	
	public int getCount(){
		return goodDao.getCount();
	}
	
	/**
	 * 根据商品类别（顶层属性）
	 */
	public List<Goods> getGoodsByGoodsType(String goodsType) {
		List<Goods> goods = new ArrayList<Goods>();
		List<Object> list = goodDao.getGoodsByGoodsType(goodsType);
		for (Object object : list) {
			goods.add((Goods) object);
		}
		
		return goods;
	}
	
	public GoodsDao getGoodDao() {
		return goodDao;
	}

	public void setGoodDao(GoodsDao goodDao) {
		this.goodDao = goodDao;
	}
}
